<template>
  <div class="container" @click="handleGalleryCilck">
    <div class="wrapper">
      <swiper ref="mySwiper" :options="swiperOptions">
        <swiper-slide v-for="(item, index) of imgs" :key="index">
          <img class="gallery_img" :src='item'>
        </swiper-slide>
      <div class="swiper-pagination"  slot="pagination"></div>
    </swiper>
    </div>
  </div>
</template>

<script>
export default {
  name: 'commonGallery',
  props: {
    imgs: {
      type: Array
    // 设置默认值方法,但是公共组件不应该有默认值
    //   default () {
    //     return ['https://imgs.qunarzz.com/sight/p0/1409/19/adca619faaab0898245dc4ec482b5722.jpg_200x200_1bc99086.jpg','https://imgs.qunarzz.com/sight/p0/2005/39/3979f1867defec4ea3.water.jpg_200x200_325a015d.jpg']
    //   }
    }
  },
  data () {
    return {
      swiperOptions: {
        autoplay: false,
        setWrapperSize: true,
        pagination: '.swiper-pagination',
        paginationType: 'fraction',
        mousewheelControl: false,
        observeParents: true,
        observer: true,
        loop: true
      }
    }
  },
  methods: {
    handleGalleryCilck () {
      this.$emit('change')
    }
  }
}
</script>
<style lang="stylus" scoped>
  .container >>> .swiper-container
    overflow inherit
  .container
    z-index 2
    position fixed
    display flex
    flex-direction column
    justify-content center
    left 0
    right 0
    bottom 0
    top 0
    background #000
    .wrapper
      width 100%
      height 0
      padding-bottom 100%
      background red
      .gallery_img
        width 100%
      .swiper-pagination
        color #fff
        bottom -1rem
</style>
